t = int(input())
for i in range(0,t):
w, x, y, z = map(int, input().split())
ans = w
min_m = min(x,y)
ans+=2*min_m
tmp = x+y-(2*min_m)+z
ans+= min(w+1,tmp)
if w==0 and x+y+z>0:
ans=1
print(ans)
// RAHUL MALAKAR 2112022
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sp setprecision
#define eb emplace_back
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define sll set<int>
#define sorti(v) sort(v.begin(), v.end())
int main()
{
ios_base::sync_with_stdio(false);
ll t;
cin >> t;
while (t--)
{
ll a, b, c, d;
cin >> a >> b >> c >> d;
if(b<c){swap(b,c);}
if(a){
cout<<a+2*c+min(a+1,b-c+d)<<endl;
}
else{cout<<1<<endl;}
}
return 0;
}
1035. Uncrossed Lines | 328. Odd Even Linked List |
1219. Path with Maximum Gold | 1268. Search Suggestions System |
841. Keys and Rooms | 152. Maximum Product Subarray |
337. House Robber III | 869. Reordered Power of 2 |
1593C - Save More Mice | 1217. Minimum Cost to Move Chips to The Same Position |
347. Top K Frequent Elements | 1503. Last Moment Before All Ants Fall Out of a Plank |
430. Flatten a Multilevel Doubly Linked List | 1290. Convert Binary Number in a Linked List to Integer |
1525. Number of Good Ways to Split a String | 72. Edit Distance |
563. Binary Tree Tilt | 1306. Jump Game III |
236. Lowest Common Ancestor of a Binary Tree | 790. Domino and Tromino Tiling |
878. Nth Magical Number | 2099. Find Subsequence of Length K With the Largest Sum |
1608A - Find Array | 416. Partition Equal Subset Sum |
1446. Consecutive Characters | 1618A - Polycarp and Sums of Subsequences |
1618B - Missing Bigram | 938. Range Sum of BST |
147. Insertion Sort List | 310. Minimum Height Trees |